<?php

class TMailer
{
    //senders name
    var $fromName             = 'user';
    //senders e-mail adress
    var $fromEmail            = "info@mydomain.com"; 
    //recipient
    var $toEmail              = "user@somedomain.com";
    // subject
    var $subject              = "Subject";
    //mail body
    var $body                 = ""; 

    protected $headers        = array();

    /***************************************************************************
    * addHeader
    ***************************************************************************/
    function __construct()
    {
    }
    
    /***************************************************************************
    * addHeader
    ***************************************************************************/
    function addHeader( $aHeader )
    {
        $this->headers[] = $aHeader;
    }
    
    /***************************************************************************
    * send
    ***************************************************************************/
    function send( $aBody = false )
    {
        if ( !$aBody )
        {
            $aBody = $this->body;
        }
        
        $headers = 'From: '.$this->fromName.' <'.$this->fromEmail.">\n";
        for( $i = 0, $n = count( $this->headers ); $i < $n; $i++ )
        {
            $headers .= $this->headers[$i]."\n";
        }
        $headers .= "\n";
        
        ini_set( 'sendmail_from', $this->fromName );
        mail( $this->toEmail, $this->subject, $aBody, $headers );
     //optional headerfields
    }

}
?>